﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows.Input;
using SqlMiM.Common.ViewModel;
using SqlMiM.Common.Commands;
using System.Collections.ObjectModel;
using System.Diagnostics;
using SqlMiM.SqlServer.Core;
using System.Windows.Threading;
using System.Collections;
using System.Windows;
using SqlMiM.SqlServer.ViewModel;
using SqlMiM.SqlServer.Model;
using MvvmFoundation.Wpf;
using SqlMiM.Common;


namespace SqlMiM.SqlServer.ServerStats
{
    public class ViewModel : ObservableObject
    {
        private BackgroundWorker bgw;

        private ServerInfo serverInfo;

        /// <summary>
        /// Server Informations
        /// </summary>
        public ServerInfo ServerInfo
        {
            get
            {
                return serverInfo;
            }
            set
            {
                serverInfo = value;
                this.RaisePropertyChanged("ServerInfo");
            }
        }


        public ViewModel()
        {
            Load();
        }


        public void Load()
        {
            bgw = new BackgroundWorker();

            bgw.DoWork += (sender, args) => { args.Result = ServerInfoServices.Current.GetServerInfos(); };

            bgw.RunWorkerCompleted += (sender, args) =>
            {
                this.ServerInfo = args.Result as ServerInfo;
            };

            bgw.RunWorkerAsync();
        }



    }


    
}
